package cn.edu.zut.bussiness;

import cn.edu.zut.DAO.StudentDao;
import cn.edu.zut.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Avegrade {
    StudentDao studentDAO;
    @Autowired
    @Qualifier(value="bdi1")
    public void setBookdao(StudentDao studentDAO){
        this.studentDAO=studentDAO;
    }
    public void insertBook(Student student){
        studentDAO.insertStudent(student);
    }
    public void onSale(float sale){
        List<Student> students=studentDAO.queryAll();
        float sum=0,i=0,ave;
        for(Student b:students){/*    b=books[i]    */
            sum=b.getGrade();
            i++;
        }
        ave=sum/i;
        System.out.println("平均成绩:"+ave);
    }
}
